<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/singIn.css">
    <script src="../lib/jquery-1.12.4.js"></script>
</head>
<body>
    <div class="heard">
        <div class="logo">
            <img src="../images/mi-logo.png" alt="">
        </div>
        <div class="heard_r">
        <h2>小米商城</h2>
        <h3>让每个人都享受科技的乐趣</h3>
        </div>
    </div>
    <div class="sing-in">
        <img src="../images/1.jpg" alt="">
        <div class="sing_in_con">
            <h2>注册</h2>
            <form action="">
                <input type="text" class="sing_user" name="user" id="username" placeholder="邮箱/手机号码/小米ID">
                <input type="password" class="sing_password" name="pass" id="password" placeholder="密码">
                <input class="btnadpt" id="login-button" type="button" value="注册">
            </form>
        </div>
    </div>
    <script>
        $("#login-button").on("click",function(){
            $.ajax({
                url:'http://localhost/src/php/singIn.php',
                type:'post',
                // dataType:'jsonp',
                data:{username:$('#username').val(),password:$('#password').val(),bool:0},
                success:function(data){
                    if(data==1){
                        alert("注册成功你可以去进行登录啦");
                        　window.location.href="http://localhost/src/pages/signIn.html";
                    }
                },
                complete:function(){
                    console.log('ajax完成了')
                },
                error:function(XMLHttpRequest, textStatus){
                    console.log(textStatus)
                    console.log('ajax发生错误了')
                },
                timeout:2000,
            })
        })
    </script>
</body>
</html>